<template>
    <div>
        <a @click="downloadFile()">下载</a>
    </div>
    
</template>
  
<script setup>
    import { useRoute, useRouter } from 'vue-router';
    import { onUnmounted } from 'vue'
    const route = useRoute()
    const router = useRouter()
    let url
    console.log("url", url)
    const unWatch = router.beforeEach((to, from, next) => {     
        url  = to.query?.url
        console.log("url:", url)
        next()
    })
    onUnmounted(()=>{
        unWatch()
    })
    const  downloadFile=()=> {
        let link = document.createElement('a');
        link.style.display = 'none';
        link.href = url;
        document.body.appendChild(link);
        link.click();
    }

</script>

<style scoped>

</style>